﻿using System;
using System.Collections.Generic;
using System.Linq;
using Viettel.VOFFICE.DAO.Models;
using Viettel.VOFFICE.Web.Helpers;

namespace Viettel.VOFFICE.Web.Models
{
    public class AppInfo
    {
        public AppInfo()
        {
        }
        public AppInfo(aspnet_Users user)
        {
            if (null != user)
            {
                var profile = UtilityHelper.GetUserProfile(user.UserName);
                if (profile != null)
                {
                    FullName = profile.FullName;
                    UserName = profile.UserName;
                    UserId = user.UserId;
                }
                Depts = user.v_UsersInDepartment.Select(o => new KeyValueModel()
                    {
                        Key = o.DeparmentId,
                        Value = o.v_Department.Name
                    }).ToList();
                if (Depts.Any())
                {
                    CurrentDept = Depts.First();
                }
            }
        }

        public string FullName { get; set; }
        public string UserName { get; set; }
        public Guid UserId { get; set; }
        public List<KeyValueModel> Depts { get; set; }
        public KeyValueModel CurrentDept { get; set; }
    }
}